/*package com.glgc.projecti.web.controller;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import org.codehaus.jackson.map.ObjectMapper;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.glgc.projecti.entity.Booking;
import com.glgc.projecti.service.IBookingService;
import com.glgc.projecti.web.controller.base.BaseController;

@Controller
@RequestMapping("/booking")
public class BookingController extends BaseController {

	@Resource
	private IBookingService bookingService;
	
	@RequestMapping(value = "/book.do", method = RequestMethod.GET, produces = "application/json")
	@ResponseBody
	public String booking(String mobileNo, String sign, String sourceType, HttpSession session) throws Exception {
		int msg = 0;
		if (mobileNo != null && mobileNo.length() == 11 && mobileNo.matches("[0-9]+")) {
			Booking findByMobileNo = bookingService.findByMobileNo(mobileNo);
			if (findByMobileNo != null) {
				msg = -1;//插入失败，已存在
			} else {
				Booking data = new Booking();
				data.setMobileNo(mobileNo);
				bookingService.saveBooking(data);
				msg = 1;//插入成功
				if (sourceType != null && !"".equals(sourceType)) {
					session.setAttribute("sourceType", sourceType);
				}
			}
			
		} else {
			msg = 2;//参数不正确
		}
		
		ObjectMapper om = new ObjectMapper();
		Map<String, Object> result = new HashMap<String, Object>();
		result.put("error_code", 0);
		result.put("error_msg", msg);
		
		return om.writeValueAsString(result);
	}
	

}
*/